﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:Design="clr-namespace:ReflectionStudio.Controls.Diagram.Components;assembly=ReflectionStudio.Controls"
                    xmlns:Ass="clr-namespace:ReflectionStudio.Core.Reflection.Types;assembly=ReflectionStudio.Core"
                    >

    <SolidColorBrush x:Key="ForegroundBrush" Color="#C0C0C0" />
    <SolidColorBrush x:Key="GroupBackgroundBrush" Color="#585858"/>
    <SolidColorBrush x:Key="OpenGroupBorderBrush" Color="#808080"/>

    <LinearGradientBrush x:Key="HeaderBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#505050" Offset="0"/>
        <GradientStop Color="#303030" Offset="1"/>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="NormalBorderBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#909090" Offset="0.0"/>
        <GradientStop Color="#303030" Offset="1.0"/>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="OpenHeaderBorderBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#C0C0C0" Offset="0.0"/>
        <GradientStop Color="#808080" Offset="1.0"/>
    </LinearGradientBrush>

    <ControlTemplate x:Key="ExpanderFunctionButton" TargetType="ToggleButton">
        <Border CornerRadius="2,0,0,0" Background="Transparent" BorderThickness="0,0,1,0">
            <Image Source="/ReflectionStudio;component/Resources/Images/16x16/assembly/assembly.png"></Image>
        </Border>
    </ControlTemplate>

    <!-- Expander style -->
    <Style x:Key="ExpanderFunctionStyle" TargetType="Expander">
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <!-- Control template for expander -->
                <ControlTemplate TargetType="Expander">
                    <Border  >
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Name="ContentRow" Height="0"/>
                            </Grid.RowDefinitions>
                            <Border Grid.Row="0" Background="{StaticResource OpenHeaderBorderBrush}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="20" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <ToggleButton  
                                        Grid.Column="0"  
                                        IsChecked="{Binding Path=IsExpanded,Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"   
                                        OverridesDefaultStyle="True"  
                                        Template="{StaticResource ExpanderFunctionButton}"  
                                        Background="{StaticResource NormalBrush}"
                                        />
                                    <ContentPresenter ContentSource="Header" RecognizesAccessKey="true"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Grid.Column="1"/>
                                </Grid>
                            </Border>
                            <Border Name="Content"  
                                Grid.Row="1"  
                                BorderThickness="1,0,1,1"  
                                CornerRadius="0,0,4,4" >
                                <ContentPresenter Margin="4" />
                            </Border>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="True">
                            <Setter TargetName="ContentRow" Property="Height"  
                                        Value="{Binding ElementName=Content,Path=DesiredHeight}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="ExpanderToggleButton" TargetType="ToggleButton">
        <Border CornerRadius="2,0,0,0" Background="Transparent" BorderThickness="0,0,1,0">
            <Image Source="/ReflectionStudio;component/Resources/Images/16x16/assembly/assembly.png"></Image>
        </Border>
    </ControlTemplate>

    <!-- Expander style -->
    <Style x:Key="ExpanderClassStyle" TargetType="Expander">
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <!-- Control template for expander -->
                <ControlTemplate TargetType="Expander">
                    <Border Name="Outline"  
                        BorderBrush="{StaticResource NormalBorderBrush}"  
                        BorderThickness="1"
                        CornerRadius="4,4,4,4"
                            >
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Name="ContentRow" Height="0"/>
                            </Grid.RowDefinitions>
                            <Border  
                Name="Border"  
                Grid.Row="0"  
                Background="{StaticResource HeaderBrush}"  
                BorderBrush="{StaticResource NormalBorderBrush}"  
                BorderThickness="1"  
                CornerRadius="4,4,0,0" >
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="20" />
                                    </Grid.ColumnDefinitions>
                                    <ToggleButton  
                                        Grid.Column="1"  
                                        IsChecked="{Binding Path=IsExpanded,Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"   
                                        OverridesDefaultStyle="True"  
                                        Template="{StaticResource ExpanderToggleButton}"  
                                        Background="{StaticResource NormalBrush}"
                                        />
                                    <StackPanel DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type Design:DesignerItem}}, Path=DataContext}">
                                        <Label Content="{Binding Path=Name}"
                                               Grid.Column="0" Margin="4"
                                               Foreground="{Binding Path=Foreground,RelativeSource={RelativeSource TemplatedParent}}"
                                                   FontSize="10" FontWeight="Bold" />
                                        <Label Content="Class"
                                               Grid.Column="0" Margin="4"
                                               Foreground="{Binding Path=Foreground,RelativeSource={RelativeSource TemplatedParent}}"
                                                   FontSize="9" />
                                        <Label Content="==>Inherited from"
                                               Grid.Column="0" Margin="4"
                                               Foreground="{Binding Path=Foreground,RelativeSource={RelativeSource TemplatedParent}}"
                                                   FontSize="9" />
                                    </StackPanel>
                                </Grid>
                            </Border>
                            
                            <ContentPresenter Grid.Row="1"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=.}"
                                />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="True">
                            <Setter TargetName="ContentRow" Property="Height"  
                                        Value="{Binding ElementName=Content,Path=DesiredHeight}" />
                            <Setter TargetName="Border" Property="BorderBrush"  
                                        Value="{StaticResource OpenHeaderBorderBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <DataTemplate x:Key="ConstructorTemplate" >
        <Label Content="{Binding Path=Name}"
               />
    </DataTemplate>
    
    <ControlTemplate x:Key="ClassItemTemplate">
        <Expander Name="classExpander" Style="{StaticResource ExpanderClassStyle}">
            <StackPanel Name="Content" >
                <Expander Header="Constructors" Style="{StaticResource ExpanderFunctionStyle}">
                    <ListBox ItemsSource="{Binding Path=Members}" SelectionMode="Single" SelectedIndex="0" 
                             ItemTemplate="{StaticResource ConstructorTemplate}">
                    </ListBox>
                </Expander>
                
            </StackPanel>
        </Expander>
    </ControlTemplate>

    <!-- AssemblyDesignerItem Style -->
    <!--<Style BasedOn="{StaticResource ItemBaseStyle}" TargetType="{x:Type Design:DesignerItem}">
        <Setter Property="ContentTemplate" Value="{StaticResource ClassItemTemplate}"/>
    </Style>-->

</ResourceDictionary>